@extends('admin.frame_layout')
<?php $top_selected = "会员管理";$page_menu = "注册内部会员" ?>
@section('content')
    <div class="formbody">
        <div class="formtitle"><span>系统内部会员注册</span></div>
        <form action="{{route('admin.reg.save')}}" method="post" id="form">
            {!! csrf_field() !!}

            {{-- 指明内部会员标识 --}}
            <input id="_in_user" name="_in_user" type="hidden" value="{{env('IN_USER_TOKEN')}}"/>
            <ul class="forminfo">

                {!! inputText("会员账号", "username", "text","",
                    "会员的登录用户名！") !!}

                {!! inputText("登录密码", "userpass", "password","",
                    "会员的登录密码！") !!}

                {!! inputText("确认登录密码", "reuserpass", "password","",
                    "重复并确认上面的密码！") !!}

                {!! inputText("交易密码", "safepass", "password","",
                    "资金操作的高级密码验证！") !!}

                {!! inputText("确认交易密码", "resafepass", "password","",
                    "重复并确认上面的密码！") !!}

                {!! inputText("推荐人", "puser", "text","",
                    "推荐人的账号！") !!}

                {!! inputText("节点人", "nuser", "text","",
                    "接点人的账号！") !!}

                {!! inputText("报单中心", "bdzx", "text","",
                    "报单中心的账号！") !!}

                <li>
                    <label class="lable">&nbsp;</label>
                    <input type="submit" class="btn" value="确认注册"/>
                </li>
            </ul>

        </form>
    </div>
@endsection
@section('footer')
    <script>
        $("#form").validate({
            rules: {
                username: {
                    required: true,
                    maxlength: 50
                },
                userpass: {
                    required: true,
                    maxlength: 30
                },
                reuserpass: {
                    equalTo: "#userpass"
                },
                safepass: {
                    required: true,
                    maxlength: 30
                },
                resafepass: {
                    equalTo: "#safepass"
                },
                puser: {
                    required: true,
                    maxlength: 50
                },
                nuser: {
                    required: true,
                    maxlength: 50
                },
                bdzx: {
                    required: true,
                    maxlength: 50
                },
            }, errorPlacement: function (error, element) {
                $(element).closest("form").find("i[for='" + element.attr("id") + "']").html(error);
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {   //注册成功去内部会员列表界面
                                window.location = "{{route('admin.users',['flag'=>5])}}";
                            }, 2000);
                        } else {
                            toastr["error"](data.msg);
                        }
                    }
                });
            }
        });
    </script>
@endsection
